using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class IconPanel : MonoBehaviour
{
    public string m_IconPath;
    public IconPanelItem m_ItemPrefab;
    public CallbackString m_OnIconSelectedCallback;
    private void Awake()
    {

        var object2 = Resources.LoadAll(m_IconPath);
        List<Sprite> objs = new List<Sprite>();
        for (int i = 0; i < object2.Length; ++i)
        {
            var gobj = object2[i] as Sprite;
            if (gobj != null)
                objs.Add(gobj);
        }

        foreach(var i in objs)
        {
            var item = Instantiate(m_ItemPrefab);
            item.Init(m_IconPath, i, this);
            item.transform.SetParent(transform);
        }

    }
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    public void Selected(IconPanelItem icon)
    {
        if (m_OnIconSelectedCallback != null)
            m_OnIconSelectedCallback(icon.m_IconPath);
    }
}
